<?php
defined('_JEXEC') or die('Restricted access');


/**
 * Custom module chrome, echos the whole module in a <div> and the header in <h{x}>. The level of
 * the header can be configured through a 'headerLevel' attribute of the <jdoc:include /> tag.
 * Defaults to <h3> if none given
 */
function modChrome_fapBox($module, &$params, &$attribs)
{
	$headerLevel = isset($attribs['headerLevel']) ? (int) $attribs['headerLevel'] : 3;

	// Se loggato
	$user = JFactory :: getUser();
	if($user->id && $params->get('moduleclass_sfx') == 'login') {
		$params->set('moduleclass_sfx', 'logout');
	} 
	
	// Se prevista voce di menù cliccabile
	$item = null;
	$link = null;
	if($params->get('itemid')) {
					
		// Catturo itemMenu richiesto
		global $mainframe;
		$item = $mainframe -> getMenu() -> getItem($params->get('itemid'));
		$link = JRoute :: _ ($item -> link . "&Itemid=" . $params->get('itemid'));
	}
	
	// Se prevista link
	if($params->get('link')) {
					
		// Catturo itemMenu richiesto
		$link = $params->get('link');
		
	}
	?>
		<div class="box box_slider <?php echo $params->get('moduleclass_sfx'); echo ($item ? " banner" : ""); ?>" <?php echo ($link ? "onclick=\"document.location.href='" . $link . "'\"" : "") ?>>
			<?php if ($module->showtitle) : ?>
				<h<?php echo $headerLevel; ?>>
				<?php if($link) {

					// Stampo link
					echo "<a href=\"" . $link . "\">" . $module->title . "</a>"; 
					
				} else { ?>
					<?php echo $module->title; ?>
				<?php } ?>
				</h<?php echo $headerLevel; ?>>
			<?php endif; ?>
			<?php echo $module->content; ?>
		</div>
	<?php
}
function modChrome_fapBox_slider($module, &$params, &$attribs)
{
	echo '<li>';
		modChrome_fapBox($module, &$params, &$attribs);
	echo '</li>';
}

